// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   check_ok.java

package ecommerce.engage;

import include.get_sql.getInsertSql;
import include.nseer_cookie.*;
import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.sql.ResultSet;
import java.util.StringTokenizer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;
import validata.ValidataNumber;
import validata.ValidataTag;

public class check_ok extends HttpServlet
{

	public check_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		try
		{
			HttpSession dbSession = request.getSession();
			JspFactory _jspxFactory = JspFactory.getDefaultFactory();
			javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
			ServletContext dbApplication = dbSession.getServletContext();
			HttpSession session = request.getSession();
			ServletContext context = session.getServletContext();
			String path = context.getRealPath("/");
			nseer_db_backup1 ecommerce_db = new nseer_db_backup1(dbApplication);
			ValidataNumber validata = new ValidataNumber();
			ValidataTag vt = new ValidataTag();
			counter count = new counter(dbApplication);
			getInsertSql getInsertSql = new getInsertSql();
			getAttachmentLength getAttachmentLength = new getAttachmentLength();
			getAttachmentType getAttachmentType = new getAttachmentType();
			if (ecommerce_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String config_id = request.getParameter("config_id");
				String release_id = request.getParameter("release_id");
				String human_major_first_kind_ID = "";
				String human_major_first_kind_name = "";
				String human_major_second_kind_ID = "";
				String human_major_second_kind_name = "";
				String human_major_first_kind = request.getParameter("select4");
				if (human_major_first_kind != null && !human_major_first_kind.equals(""))
				{
					for (StringTokenizer tokenTO4 = new StringTokenizer(human_major_first_kind, "/"); tokenTO4.hasMoreTokens();)
					{
						human_major_first_kind_ID = tokenTO4.nextToken();
						human_major_first_kind_name = tokenTO4.nextToken();
					}

				}
				String human_major_second_kind = request.getParameter("select5");
				if (human_major_second_kind != null && !human_major_second_kind.equals(""))
				{
					for (StringTokenizer tokenTO5 = new StringTokenizer(human_major_second_kind, "/"); tokenTO5.hasMoreTokens();)
					{
						human_major_second_kind_ID = tokenTO5.nextToken();
						human_major_second_kind_name = tokenTO5.nextToken();
					}

				}
				String engage_type = request.getParameter("engage_type");
				String human_amount = request.getParameter("human_amount");
				String deadline = request.getParameter("deadline");
				String bodyb = new String(request.getParameter("remark1").getBytes("UTF-8"), "UTF-8");
				String remark1 = exchange.toHtml(bodyb);
				String bodyc = new String(request.getParameter("remark2").getBytes("UTF-8"), "UTF-8");
				String remark2 = exchange.toHtml(bodyc);
				String bodyd = new String(request.getParameter("opinion").getBytes("UTF-8"), "UTF-8");
				String opinion = exchange.toHtml(bodyd);
				String checker_ID = request.getParameter("checker_ID");
				String checker = request.getParameter("checker");
				String check_time = request.getParameter("check_time");
				int j = 0;
				String sql6 = (new StringBuilder("select * from ecommerce_workflow where object_id='")).append(release_id).append("' and ((check_tag='0' and config_id<'").append(config_id).append("') or (check_tag='1' and config_id='").append(config_id).append("'))").toString();
				ResultSet rs6 = ecommerce_db.executeQuery(sql6);
				if (!rs6.next() && vt.validata((String)session.getAttribute("unit_db_name"), "hr_major_release", "release_id", release_id, "check_tag").equals("0"))
				{
					if (j == 0)
					{
						String sql1 = (new StringBuilder("select * from hr_major_release where release_id='")).append(release_id).append("'").toString();
						ResultSet rs = ecommerce_db.executeQuery(sql1);
						rs.next();
						String sqla = (new StringBuilder("update hr_major_release set human_major_first_kind_ID='")).append(human_major_first_kind_ID).append("',human_major_first_kind_name='").append(human_major_first_kind_name).append("',human_major_second_kind_ID='").append(human_major_second_kind_ID).append("',human_major_second_kind_name='").append(human_major_second_kind_name).append("',human_amount='").append(human_amount).append("',engage_type='").append(engage_type).append("',deadline='").append(deadline).append("',remark1='").append(remark1).append("',remark2='").append(remark2).append("',opinion='").append(opinion).append("'").toString();
						String sqlb = (new StringBuilder(" where release_id='")).append(release_id).append("'").toString();
						String sql = (new StringBuilder(String.valueOf(sqla))).append(sqlb).toString();
						ecommerce_db.executeUpdate(sql);
						sql = (new StringBuilder("update ecommerce_workflow set check_tag='1',checker_ID='")).append(checker_ID).append("',checker='").append(checker).append("',check_time='").append(check_time).append("' where object_id='").append(release_id).append("' and config_id='").append(config_id).append("'").toString();
						ecommerce_db.executeUpdate(sql);
						sql6 = (new StringBuilder("select * from ecommerce_workflow where object_id='")).append(release_id).append("' and check_tag='0'").toString();
						rs6 = ecommerce_db.executeQuery(sql6);
						if (!rs6.next())
						{
							sql = (new StringBuilder("update hr_major_release set check_tag='1',checker_ID='")).append(checker_ID).append("',checker='").append(checker).append("',check_time='").append(check_time).append("' where release_id='").append(release_id).append("'").toString();
							ecommerce_db.executeUpdate(sql);
						}
						response.sendRedirect((new StringBuilder("ecommerce/engage/check_ok_a.jsp?release_id=")).append(release_id).toString());
					} else
					{
						response.sendRedirect("ecommerce/engage/check_ok_b.jsp");
					}
				} else
				{
					response.sendRedirect("ecommerce/engage/check_ok_c.jsp");
				}
				ecommerce_db.commit();
				ecommerce_db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
